package com.newcoretech.platform_service

///
/// --author: xie jiayan
/// --created on: 2020-03-10 10:17
/// --description:
///
import android.app.Activity
import android.content.Context
import android.util.Log
import androidx.lifecycle.Lifecycle
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.StandardMessageCodec
import io.flutter.plugin.platform.PlatformView
import io.flutter.plugin.platform.PlatformViewFactory

class AndroidFlutterViewFactory(private val activity: Activity,private val methodCall: MethodChannel,val lifecycle: Lifecycle?=null): PlatformViewFactory(StandardMessageCodec.INSTANCE) {
    private var scannerView: QRScannerView? = null

    override fun create(context: Context?, id: Int, args: Any?): PlatformView {
        val params = args?.let { args as Map<String, Any> }
        scannerView = QRScannerView(activity, methodCall, id, params,lifecycle)
        Log.i("FVFactory", "onCreate")
        return scannerView!!
    }


    fun error(tag: String, message: String){
        scannerView?.error(tag, message)
    }

    fun start(){
        scannerView?.start()
    }
}









